//
//  GZGroupBuyingCell.m
//  A01- 团购
//
//  Created by Rainy Zou on 15/11/22.
//  Copyright © 2015年 Rainy Zou. All rights reserved.
//

#import "GZGroupBuyingCell.h"
#import "CZGroupBuying.h"
@interface GZGroupBuyingCell()
@property (weak,nonatomic) IBOutlet UIImageView *iconView;
@property (weak,nonatomic) IBOutlet UILabel *titleView;
@property (weak,nonatomic) IBOutlet UILabel *priceView;
@property (weak,nonatomic) IBOutlet UILabel *buyCountView;


@end

@implementation GZGroupBuyingCell


//创建可重用的cell
+ (instancetype)groupBuyingCellWithTableView:(UITableView *)tableView
{
    static NSString *reuseId = @"cell";
    GZGroupBuyingCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseId];
    if(cell == nil){
        cell = [[[NSBundle mainBundle] loadNibNamed:@"CZGroupBuyingCell" owner:nil options:nil] lastObject];
    }
    
    return cell;
}

//重写属性的 setter方法
- (void)setGroupBuying:(CZGroupBuying *)groupBuying
{
    _groupBuying = groupBuying;
    self.titleView.text = groupBuying.title;
    self.priceView.text = [NSString stringWithFormat:@"￥ %@",groupBuying.price];
    [self.iconView setImage:[UIImage imageNamed:groupBuying.icon]];
    self.buyCountView.text = [NSString stringWithFormat:@"%@人已购买",groupBuying.buyCount];
}

@end
